<?php

namespace common\jobs\base;

use Yii;
use yii\helpers\ArrayHelper;

/**
 * 基础任务类
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class BaseJobHandleModel extends \common\base\Model {

    /**
     * 记录日志并取消任务执行
     */
    public $job = null;

    /**
     * 记录日志并取消任务执行
     */
    public function dumpError($message = null, $error = null, $code = 508) {
        Yii::error($message);
        return false;
    }

    /**
     * 输出模型错误
     * @param string $message 错误信息
     * @param \yii\base\Model|false|null $error 扩展错误对象
     * @param integer $code 错误码
     * @throws ModelHttpException
     */
    public function dumpRetryError($message = '', $trigger = IntervalRetryJobException::TRIGGER_FULL_DAY) {
        Yii::error($message, __METHOD__);
        Yii::error($this->job, __METHOD__);
        throw new IntervalRetryJobException($trigger, $this->job, $message);
    }

}
